<?php
abstract class DB{

	protected $db_cfg = array('dbType'=>'','dbHost'=>'','dbPort'=>'','dbName'=>'','dbUser'=>'','dbPwd'=>'','dbPrefix'=>'','dbCharset'=>'');
	protected $sql = "";
	protected $err = array();
	protected $conn = null;

	static function init(& $CONFIGS){
		$instance = empty($CONFIGS['dbType']) ? 'mysql' : $CONFIGS['dbType'];
		if( !file_exists(__LIB__.'drivers/'.$instance.'.class.php') ){
			die("File $instance.class.php not found.");
		}
		include_once(__LIB__.'drivers/'.$instance.'.class.php');
		$instance = 'v_'.$instance;
		return new $instance($CONFIGS);
	}

	public function get_sql(){
		return $this->sql;
	}

	abstract function query($sql);
	abstract function fetch($result, $result_type=1);
	abstract function insert_id();
	abstract function affected_rows();
	abstract function error();
	abstract function close();
}
